import { Injectable } from '@angular/core';
import { HttpClient } from "@angular/common/http";

import * as  turf from '@turf/turf';
import { map } from 'rxjs/operators';
import { DynamicDataQueryURL, RAIN_FALL_URL, WATER_LEVEL, StatsURL } from './Constants';
import { environment } from 'src/environments/environment';
@Injectable({
  providedIn: 'root'
})
export class OverviewService {

  // public statsURL = "mock-data/stats.json"
  // public dynamicDataQueryURL = "http://test.cityfun.com.cn/api/test/pipeline/PipelineDynamicDataQuery"

  constructor(
    private http: HttpClient,
  ) { }

  public getDynamicPipeLine(params) {
    return this.http.get<any>(DynamicDataQueryURL, { params })
  }

  // 获取统计信息
  public getStatsData(id) {
    return this.http.get<any>(StatsURL).pipe(
      map(data => data[id])
    )
  }

  // 降雨量
  public getRainFallData(params) {
    return this.http.get<any>( environment.api_fallrain, /*RAIN_FALL_URL*/{ params })
  }
  // 水位编码
  public geWaterCodeByName(params) {
    return this.http.get<any>(environment.api_waterlevel,/*WATER_LEVEL*/ { params })
  }

  // 水位数据
  public geWaterLeveDatalByCode(params) {
    return this.http.get<any>(environment.api_waterlevdata, { params }) }
}
